local blaze = require "blaze"
local game = require "club.threecard.sudoku"

local SimpleList = require "blaze.ui.widget.SimpleList"
local HeartState = require "club.threecard.sudoku.ui.common.HeartState"

local M = blaze.class(SimpleList)

function M:ctor()
    self.current = 0
    self.max = 0
end

function M:create_item(data, index)
    return HeartState.new(data, index)
end

function M:set_value(current, max)
    if current == self.current and max == self.max then
        return
    end
    local wrong = max - current
    local data = {}
    for i = 1, max do
        table.insert(data, i <= wrong and 0 or 1)
    end
    self:fill(data)
end

return M